<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- 引入easyui 的主题样式  和  easyui 提供的图标样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css"  charset=UTF-8/>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css"  charset=UTF-8/>
<!-- 引入jquery 和  easyui.js   中文设置js-->
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js" charset=UTF-8></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js" charset=UTF-8></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js" charset=UTF-8></script>
</head>
<script type="text/javascript">
$(function(){
	$('#dg').datagrid({
		url:'sqsp',
		columns:[[  
				{field:'ck',checkbox:true,width:100},       
			    {field:'sid',title:'学生学号',width:100}, 
			    {field:'tname',title:'教师姓名',width:100},    
			    {field:'cname',title:'课程名称',width:100},
			    {field:'score',title:'分数',width:40},
			    {field:'nr',title:'申请内容',width:100},
			    {field:'zt',title:'状态',width:100},
			    {field:'sj',title:'申请时间',width:200,align:'right'},
		]],
		pageSize:5,
	    pagePosition:'bottom',
	    pagination:true,
	    pageList:[5,6,7],
	    rownumbers:true,
	    toolbar: [{
	    	iconCls: 'icon-edit',
	    	text:'同意申请',
	    	handler: function(){
	    		var  ck = $('#dg').datagrid('getSelections');
	    		if(ck.length==1){
	    			var sid = ck[0].sid;
	    			var id = ck[0].id;
		    		var tname = ck[0].tname;
		    		var cname = ck[0].cname;
		    		var nr = ck[0].nr;
		    		var sj = ck[0].sj;
		    		var score = ck[0].score;
		    		$.ajax({
		    			url:'passsq', //同意申请请求
		    			type:'post',
		    			data:{'sid':sid,'id':id,'tname':tname,'cname':cname,'nr':nr,'sj':sj,'score':score},
		    			datatype:'text',
		    			success:function(data){
		    				if(data=="1"){
		    					$.messager.alert('success','操作成功','info');
		    					$('#dg').datagrid('reload');
		    					$('#dg').datagrid('uncheckAll');
		    				}else{
		    					$.messager.alert('error','操作失败','info');
		    					$('#dg').datagrid('uncheckAll');
		    				}
		    			}
		    		})
	    		}else{
	    			$.messager.alert('error','请只选择一个数据，慢慢来，看仔细点！','info');
	    		}	
	    	}
	    },'-',{
	    	iconCls: 'icon-edit',
	    	text:'驳回申请',
	    	handler: function(){
	    		var  ck = $('#dg').datagrid('getSelections');
	    		if(ck.length==1){
	    			var sid1 = ck[0].sid;
	    			var id1 = ck[0].id;
		    		var tname1 = ck[0].tname;
		    		var cname1 = ck[0].cname;
		    		var nr1 = ck[0].nr;
		    		var sj1 = ck[0].sj;
		    		var score1 = ck[0].score;
		    		$.ajax({
		    			url:'reject',
		    			type:'post',
		    			data:{'id':id1,'sid':sid1,'tname':tname1,'cname':cname1,'nr':nr1,'sj':sj1,'score':score1},
		    			datatype:'text',
		    			success:function(data){
		    				if(data=="1"){
		    					$.messager.alert('success','操作成功','info');
		    					$('#dg').datagrid('reload');
		    					$('#dg').datagrid('uncheckAll');
		    				}else{
		    					$.messager.alert('error','操作失败','info');
		    					$('#dg').datagrid('uncheckAll');
		    				}
		    			}
		    		})
	    		}else{
	    			$.messager.alert('error','一个一个的操作！','info');
	    		}
	    	}
	    }]
	    
	})
})
</script>
<body>
	<!--  申请内容表  -->
	<table id="dg" ></table>
</body>
</html>